package com.omuao.message.queue.api.poll.scheduler;

import com.omuao.message.queue.service.poll.PollAutoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 自动作业
 *
 * @author omuao
 */
@EnableScheduling
@Configuration
public class PollAutoScheduler {

    /**
     * 日志
     */
    public static Logger logger = LoggerFactory.getLogger(PollAutoScheduler.class);

    /**
     * 自动出队列消息
     */
    @Autowired
    PollAutoService pollAutoService;

    /**
     * 整理压缩
     */
    @Scheduled(fixedRate = 24 * 60 * 60 * 1000)
    public void compact() {
        pollAutoService.compact();
    }

    /**
     * 清理超时消息
     */
    @Scheduled(fixedRate = 50)
    public void clearTimeoutMessage() {
        pollAutoService.clearTimeoutMessage();
    }

    /**
     * 清理超时模板消息
     */
    @Scheduled(fixedRate = 50)
    public void clearTemplateTimeoutMessage() {
        pollAutoService.clearTemplateTimeoutMessage();
    }

}
